<!--
 * @Author: 高瑞寒 15932717091@163.com
 * @Date: 2022-04-25 10:33:22
 * @LastEditTime: 2022-04-25 10:58:53
 * @LastEditors: 高瑞寒 15932717091@163.com
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="test"></div>
  <script type="text/javascript" src="../js/react.development.js"></script>
  <script type="text/javascript" src="../js/react-dom.development.js"></script>
  <script type="text/javascript" src="../js/babel.min.js">
  </script>
  <script src="../js/prop-types.js"></script>
  <script type="text/babel">
    /* 
    理解:组件由ref控制查询DOM,不受开发者控制
    */
    class MyComponent extends React.Component {
      submit = (e) => {
        alert('用户名' + this.username.value + '密码' + this.password.value);
        return false
      }
      render() {
        return (
          <form action="www.baidu.com" onSubmit={this.submit}>
            <input type="text" ref={e => this.username = e} />
            <input type="password" ref={e => this.password = e} />
            <button>提交</button>
          </form>
        )
      }
    }
    ReactDOM.render(<div><MyComponent /></div>, document.querySelector('#test'))

  </script>
</body>

</html>